package de.hm.edu.c2dm;

import java.sql.SQLException;
import java.util.ArrayList;

import de.hm.edu.oradb.IDbConnection;
import de.hm.edu.oradb.OracleDbConnectionImpl;

/** 
 * A helper class to handle the C2DM Server Registration
 * 
 * @author Peter Goldenbogen (Munich University of Applied Science)
 * @version 1.0 
 */
public class C2dmRecipientsContainer {
	
	private ArrayList<String> recipients;
	IDbConnection conn;
	
	public C2dmRecipientsContainer(){
		conn = new OracleDbConnectionImpl();
		this.getRecipients();
	}
	
	public void addRecipient(String registrationId){
		
		try {
			conn.insertC2dmRecipient(registrationId);
		} catch (SQLException e) {
			System.out.println(e.getMessage());
		}
	}

	public ArrayList<String> getRecipients() {
		
		try {
			this.recipients = conn.getc2dmRecipients();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return this.recipients;
	}

	public void setRecipients(ArrayList<String> recipients) {
		this.recipients = recipients;
	}
	
	

}
